<div id="test1"></div>
<script type="text/javascript">
    var x = 0

    function showval() {
        x++;
        return x;
    }

    setInterval(function () {
        document.getElementById('test1').innerHTML = showval();
    }, 1000);

</script>